home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wlib11_4.zip / HEADERS.EXE / WINDOW.H < prev    next >
Text File  |  1991-02-27  |  21KB  |  456 lines

  1. /*** WINDOW.H ***/
  2.  
  3. /* Written By P.A. McKenzie
  4.  * The C Window Library
  5.  * Copyright (C) 1990   All Rights Reserved
  6. */
  7. #if !defined (WINDOW_DEF)
  8. #define WINDOW_DEF
  9.  
  10. #ifndef UNKNOWNARGS
  11. #ifndef __cplusplus
  12. #define UNKNOWNARGS
  13. #else
  14. #define UNKNOWNARGS ...
  15. #endif
  16. #endif
  17.  
  18. /* Window definitions */
  19.  
  20. #if !defined (MISC_DEF)
  21. #  define MISC_DEF
  22. #  include "misc.h"
  23. #endif
  24.  
  25. #if defined (GLOBAL_DEF)
  26. #define EXTERN
  27. #else
  28. #define EXTERN  extern
  29. #endif
  30.  
  31. #define CWL_NULL     ((char *)0)
  32.  
  33. #include "uscore.h"           /* resolves Lattice underscore diffferences */
  34. #include "key.h"              /* Key definitions */
  35. #include "wstruct.h"          /* Window structures */
  36. #include "werror.h"           /* Window error codes */
  37. #include "proto.h"            /* Prototype macro */
  38. #include "cursor.h"           /* cursor routines */
  39. #include "source.h"
  40.  
  41.  
  42.  
  43.  
  44. /* define window manifest constants */
  45.  
  46. #define WIN_NULL_PTR    ((WPOINTER)0)   /* Null Window Pointer */
  47. #define VWIN_NULL_PTR   ((VWPOINTER)0)  /* Null virtual window pointer */
  48. #define VBLOCK_NULL_PTR ((VBLOCKPTR)0)  /* Null video block pointer */
  49.  
  50. /* Other defines */
  51.  
  52. #define SAVE          0
  53. #define RESTORE       1
  54.  
  55. #define BORDER        1
  56. #define NOBORDER      0
  57.  
  58. #define NOATTRIBUTE 0
  59. #define ATTRIBUTE   1
  60.  
  61. #define TRUE          1
  62. #define FALSE         0
  63.  
  64. #define MAXWIDTH      140     /* Maximum width of the screen in columns */
  65. #define MAXCOLS       140     /* Maximum columns in a normal window */
  66.  
  67. #define MAXHEIGHT     80      /* Maximum height of a normal window */
  68. #define MAXBUFSIZE    1024    /* Maximum internal write buffer size */
  69.  
  70. #define DMA           1       /* Direct Screen write */
  71. #define BIOS          0       /* BIOS screen write */
  72.  
  73. #define WRAP          1       /* Wrap flag in window */
  74. #define CLIP          0       /* Clip output in window */
  75.  
  76. #define ANCHORLEFT    1
  77. #define ANCHORRIGHT   2
  78. #define ANCHORTOP     1
  79. #define ANCHORBOTTOM  2
  80.  
  81. #define UP            1
  82. #define DOWN          2
  83. #define LEFT          3
  84. #define RIGHT         4
  85.  
  86. #define MAXTAB        50      /* Maximum tab size in windows */
  87. #define DEFTAB        4       /* Default tab size */
  88.  
  89.  
  90. #define MAXPAGES      16      /* Maximum number of video pages */
  91. #define MAXWINDOWS    255     /* Maximum windows including base screen */
  92.  
  93. #define SHADOWUPLEFT   1      /* Shadow position */
  94. #define SHADOWUPRIGHT  2      /*       "         */
  95. #define SHADOWLOWLEFT  3      /*       "         */
  96. #define SHADOWLOWRIGHT 4      /*       "         */
  97.  
  98. #define WINDOWCHECK    1      /* Check constant  */
  99. #define WINOPENCHECK   2      /* Check constant  */
  100. #define VWINDOWCHECK   4      /* Check constant  */
  101.  
  102. /* Explosion effects */
  103. #define NOEFFECT       0
  104. #define EXPLODE        1
  105. #define CONTRACT       2
  106. #define BRICKS         3
  107. #define MIDDLEROWOUT   4
  108. #define TOPBOTTOMIN    5
  109. #define TOPDOWN        6
  110. #define BOTTOMUP       7
  111. #define MIDDLECOLOUT   8
  112. #define LEFTRIGHTIN    9
  113. #define LEFTTORIGHT   10
  114. #define RIGHTTOLEFT   11
  115.  
  116. #define MAX_SPECIAL_EFFECT  11
  117.  
  118.  
  119. /* define is... macros */
  120. #define ISBORDER(w)          (int) (((w)->stat_info.border_flag)?1:0)
  121. #define ISWRAP(w)            (int) (((w)->stat_info.wrap_flag)?1:0)
  122. #define ISOPEN(w)            (int) (((w)->stat_info.open_flag)?1:0)
  123. #define ISVISIBLE(w)         (int) (((w)->stat_info.visible_flag)?1:0)
  124. #define ISVIEWPORT(w)        (int) (((w)->stat_info.v_window_flag)?1:0)
  125. #define ISWINDOW(vw)         (int) (((vw)->stat_info.viewport_flag)?1:0)
  126. #define ISBUFSAVE(w)         (int) (((w)->stat_info.bufptr_flag)?1:0)
  127. #define ISSEETHRU(w)         (int) (((w)->stat_info.seethru_flag)?1:0)
  128. #define ISINITIAL(w)         (int) (((w)->stat_info.init_flag)?1:0)
  129. #define ISFROZEN(w)          (int) (((w)->stat_info.frozen_flag)?1:0)
  130. #define ISSHADOW(w)          (int) \
  131.                               (((w)->shadow_info.shadow_stat.shadow_flag)?1:0)
  132. #define ISSHADOWTRANS(w)     (int) \
  133.                               (((w)->shadow_info.shadow_stat.shadow_trans)?1:0)
  134.  
  135. /* Shadow macros */
  136. #define SHADOW_POS(w)        (int)(((w)->shadow_info.shadow_stat.shadow_pos))
  137. #define SHADOW_CHAR(w)       (int)(((w)->shadow_info.schar))
  138. #define SHADOW_ATTR(w)       (int)(((w)->shadow_info.sattr))
  139. #define SHADOW_WIDTH(w)      (int)(((w)->shadow_info.swidth))
  140. #define SHADOW_HEIGHT(w)     (int)(((w)->shadow_info.sheight))
  141.  
  142.  
  143. #define VWTYPE(vw)      (int) ((vw)->stat_info.vwtype)
  144. #define VWWRAP(vw)      (vw)->stat_info.wrap_flag
  145.  
  146. #define EDGES(w)              ((int)((ISBORDER((w))?2:0)))
  147. #define EDGEDIF(w)            ((int)((ISBORDER((w))?1:-1)))
  148. #define WLASTROW(w)           ((int)((w)->row+(w)->height+EDGEDIF(w)))
  149. #define WLASTCOL(w)           ((int)((w)->col+(w)->width+EDGEDIF(w)))
  150.  
  151.  
  152. /* Existence macros */
  153. #define WINDOW_EXIST(w)  \
  154.                   ((window_ptrs[(w)->wnum] != (w) || (w) == WIN_NULL_PTR)?0:1)
  155.  
  156. #define VIRTUAL_WINDOW_EXIST(vw) \
  157.                       (((virtual_window_ptrs[(vw)->wnum] != (vw)) || \
  158.                          (vw) == VWIN_NULL_PTR)?0:1)
  159.  
  160. /* General window macros */
  161.  
  162. #define VIEWPORT_ROW(w)         ((w)->vwrow)
  163. #define VIEWPORT_COLUMN(w)      ((w)->vwcol)
  164. #define VIRTUAL_WINDOW(w)       ((w)->vwptr)
  165. #define WINDOW_RANK(w)          ((w)->rank)
  166. #define WINDOW_TEXT_COLOR(w)    ((w)->wattr)
  167. #define WINDOW_BORDER_COLOR(w)  ((w)->battr)
  168. #define WINDOW_PAGENUM(w)       ((w)->pagenum)
  169. #define WINDOW_WIDTH(w)         ((w)->width)
  170. #define WINDOW_HEIGHT(w)        ((w)->height)
  171. #define WINDOW_ROW(w)           ((w)->row)
  172. #define WINDOW_COLUMN(w)        ((w)->col)
  173. #define VWINDOW_COORD_IN_VIEWPORT(w,row,col) \
  174.                                    ((((col) >= (w)->vwcol) && \
  175.                                    ((col) <= (w)->vwcol+(w)->width-1) && \
  176.                                    ((row) >= (w)->vwrow) && \
  177.                                    ((row) <= (w)->vwrow+(w)->height-1))?1:0)
  178.  
  179.  
  180.  /*****************************
  181.   * Define external variables *
  182.   ****************************/
  183.  
  184. /*** Colors  ***/
  185.  
  186. EXTERN int black;
  187. EXTERN int blue;
  188. EXTERN int green;
  189. EXTERN int cyan;
  190. EXTERN int red;
  191. EXTERN int magenta;
  192. EXTERN int brown;
  193. EXTERN int white;
  194. EXTERN int gray;
  195. EXTERN int lightblue;
  196. EXTERN int lightgreen;
  197. EXTERN int lightcyan;
  198. EXTERN int lightred;
  199. EXTERN int lightmagenta;
  200. EXTERN int yellow;
  201. EXTERN int lightwhite;
  202.  
  203. EXTERN unsigned window_edit_key[12];
  204.                          /* stores info on keys that are used for the
  205.                                     window input functions */
  206. EXTERN WPOINTER *window_trans;     /* array of transparent windows */
  207. EXTERN int window_error_code;      /* window error number */
  208. EXTERN int check_existence_flag;
  209. EXTERN int override_seethru;       /* Overrides seethru window in
  210.                                     *  screen_image */
  211. EXTERN char input_mask_char;       /* Mask character to use for input mask */
  212. EXTERN int max_window_rank;        /* maximum rank number */
  213. EXTERN int min_window_rank;        /* lowest rank number */
  214. EXTERN int mouse_found;            /* returns 1 if mouse found */
  215.  
  216. EXTERN unsigned explosion_speed[MAX_SPECIAL_EFFECT+1];
  217.                                /* Speed of explosions for windows in
  218.                                 * milliseconds */
  219.  
  220. EXTERN int num_transparent_shadows[MAXPAGES];  /* Number of shadows */
  221. EXTERN int total_transparent_shadows;          /* Number of transparent
  222.                                                   shadows */
  223.  
  224. EXTERN unsigned char *screen_image[MAXPAGES]; /* pointer to screen members */
  225. EXTERN WPOINTER   window_rank[MAXWINDOWS+2];
  226.                               /* array of windows in rank order */
  227. EXTERN WPOINTER   window_ptrs[MAXWINDOWS+1];  /* array of windows in declaration
  228.                                                 order */
  229. EXTERN WPOINTER   orig_screen[MAXPAGES];
  230. EXTERN char far   *screen_page_offset[MAXPAGES];
  231. EXTERN VWPOINTER  virtual_window_ptrs[MAXWINDOWS+1];
  232. EXTERN void       (*window_error_func) P((int errorcode, char *sourcefile,
  233.                                           int sourceline, char *funcname));
  234.  
  235.  
  236. #if __cplusplus
  237.   extern "C" {
  238. #endif
  239.  
  240. /* Miscellaneous Routines */
  241. void          AdjustGlobalData P((void));
  242. int           AdjustScreenInfo P((int page));
  243. char *        CharToString P((int));
  244. char *        CreateRepeatedString P((char *str, int num));
  245. void          MakeSound P((unsigned freq, unsigned millisec));
  246. char *        TranslateMaskStringToString P((char *str, char *mask, char *str2,
  247.                                              int mchar));
  248. char *        TranslateStringToMaskString P((char *str, char *mask, char *str2,
  249.                                              int mchar, int flag));
  250. int           TranslateMaskPosToStringPos P((char *, int, int));
  251. int           TranslateStringPosToMaskPos P((char *, int, int));
  252.  
  253. int           VirtualClear P((VWPOINTER vw));
  254. int           VirtualClearAttr P((VWPOINTER vw, int attr));
  255. int           VirtualClearRegion P((VWPOINTER vw, unsigned urow, unsigned ucol,
  256.                                     unsigned lrow, unsigned lcol));
  257. int           VirtualClearRegionAttr P((VWPOINTER vw, unsigned urow,
  258.                                         unsigned ucol, unsigned lrow,
  259.                                         unsigned lcol, int attr));
  260. int           VirtualFree P((VWPOINTER vw, int hideflag, int effect));
  261. int           VirtualGetCursorPosition P((VWPOINTER vw, unsigned *row,
  262.                                           unsigned *col));
  263. VWPOINTER     VirtualInitialize P((int vwtype, unsigned nrows, unsigned ncols,
  264.                                    int attr));
  265. int           VirtualMoveCursor P((VWPOINTER vw, unsigned row, unsigned col));
  266. int           VirtualPrintf P((VWPOINTER vw, char *format, ...));
  267. int           VirtualPrintfAttr P((VWPOINTER vw, int attr, char *format, ...));
  268. int           VirtualReadAttributes P((VWPOINTER vw, char *buffer, unsigned row,
  269.                                        unsigned col, unsigned length));
  270. int           VirtualReadCharacters P((VWPOINTER vw, char *buffer, unsigned row,
  271.                                        unsigned col, unsigned length));
  272. int           VirtualReadCharAndAttr P((VWPOINTER vw, char *buffer, unsigned row,
  273.                                         unsigned col, unsigned length));
  274. int           VirtualSetWrap P((VWPOINTER vw, int wrapflag));
  275. int           VirtualWriteAttributes P((VWPOINTER vw, char *buffer, unsigned row,
  276.                                         unsigned col, unsigned length));
  277. int           VirtualWriteCenterString P((VWPOINTER vw, char *string,
  278.                                           unsigned row));
  279. int           VirtualWriteCenterStringAttr P((VWPOINTER vw, char *string,
  280.                                               unsigned row, int attr));
  281. int           VirtualWriteCharacters P((VWPOINTER vw, char *buffer, unsigned row,
  282.                                         unsigned col, unsigned length));
  283. int           VirtualWriteCharAndAttr P((VWPOINTER vw, char *buffer, unsigned row,
  284.                                          unsigned col, unsigned length));
  285. int           VirtualWriteRepeatAttribute P((VWPOINTER vw, int attr, unsigned row,
  286.                                              unsigned col, unsigned length));
  287. int           VirtualWriteRepeatCharacter P((VWPOINTER vw, int ch, unsigned row,
  288.                                              unsigned col, unsigned length));
  289. int           VirtualWriteString P((VWPOINTER vw, char *string, unsigned row,
  290.                                     unsigned col));
  291. int           VirtualWriteStringAttr P((VWPOINTER vw, char *string, unsigned row,
  292.                                         unsigned col, int attr));
  293. int           VirtualWriteStringCC P((VWPOINTER vw, char *string, unsigned row,
  294.                                       unsigned col));
  295. int           VirtualWriteStringCCAttr P((VWPOINTER vw, char *string,
  296.                                           unsigned row, unsigned col, int attr));
  297. int           VirtualWriteStringRJ P((VWPOINTER vw, char *string, unsigned row,
  298.                                       unsigned col));
  299. int           VirtualWriteStringRJAttr P((VWPOINTER vw, char *string,
  300.                                           unsigned row, unsigned col, int attr));
  301. int           VirtualWriteTextToFile P((VWPOINTER vw, char *filename, int mode));
  302.  
  303. /* Window Functions */
  304. int           WindowAssignToVirtual P((WPOINTER w, VWPOINTER vw, unsigned row,
  305.                                        unsigned col));
  306. int           WindowClose P((WPOINTER w, int effect));
  307. int           WindowChangeCursor P((WPOINTER w, int shape));
  308. int           WindowChangeBorderAttribute P((WPOINTER w, int attr));
  309. int           WindowChangeTextAttribute P((WPOINTER w, int attr));
  310. int           WindowClear P((WPOINTER w));
  311. int           WindowClearAttr P((WPOINTER w, int attr));
  312. int           WindowClearRegion P((WPOINTER w, int urow, int ucol, int lrow,
  313.                                    int lcol));
  314. int           WindowClearRegionAttr P((WPOINTER w, int urow, int ucol, int lrow,
  315.                                        int lcol, int attr));
  316. int           WindowCloseViewport P((WPOINTER w, int hide, int effect));
  317. int           WindowDisplay P((WPOINTER w, int rank, int effect));
  318. int           WindowDrawBox P((WPOINTER w, int urow, int ucol, int lrow,
  319.                                int lcol, char *box));
  320. int           WindowDrawBoxAttr P((WPOINTER w, int urow, int ucol, int lrow,
  321.                                    int lcol, char *box, int attr));
  322. int           WindowDrawBorder P((WPOINTER w, char *box));
  323. int           WindowDrawShadow P((WPOINTER w, int spos, int swidth,
  324.                                   int sheight, int schar, int sattr, int tflag));
  325. int           WindowFree P((WPOINTER w, int effect));
  326. int           WindowFreeze P((WPOINTER w, int flag));
  327. int           WindowGetCursorPosition P((WPOINTER w, int *row, int *col));
  328.  
  329. int           WindowGetMaskPassword P((WPOINTER w, int row, int col,
  330.                                        char *buffer, char *mask, int fillchar,
  331.                                        int passchar, int minchars, int maxwidth,
  332.                                        int options, char *regexp));
  333.  
  334. int           WindowGetMaskPasswordAttr P((WPOINTER w, int row, int col,
  335.                                            char *buffer, char *mask,
  336.                                            int fillchar, int passchar,
  337.                                            int minchars, int maxwidth,
  338.                                            int options, int attr, char *regexp));
  339.  
  340. int           WindowGetMaskString P((WPOINTER w, int row, int col, char *buffer,
  341.                                      char *mask, int fillchar, int minchars,
  342.                                      int maxwidth, int options, char *regexp));
  343.  
  344. int           WindowGetMaskStringAttr P((WPOINTER w, int row, int col,
  345.                                          char *buffer, char *mask, int fillchar,
  346.                                          int minchars, int maxwidth,
  347.                                          int options, int attr, char *regexp));
  348.  
  349. int           WindowGetPassword P((WPOINTER w, int row, int col, char *buffer,
  350.                                    int fillchar, int passchar, int minchars,
  351.                                    int maxwidth, int options, char *regexp));
  352.  
  353. int           WindowGetPasswordAttr P((WPOINTER w, int row, int col,
  354.                                        char *buffer, int fillchar, int passchar,
  355.                                        int minchars, int maxwidth, int options,
  356.                                        int attr, char *regexp));
  357.  
  358. int           WindowGetString P((WPOINTER w, int row, int col, char *buffer,
  359.                                  int fillchar, int minchars, int maxwidth,
  360.                                  int options, char *regexp));
  361.  
  362. int           WindowGetStringAttr P((WPOINTER w, int row, int col, char *buffer,
  363.                                      int fillchar, int minchars, int maxwidth,
  364.                                      int options, int attr,char *regexp));
  365.  
  366. int           WindowHide P((WPOINTER w, int effect));
  367. WPOINTER      WindowInitialize P((int bordflag, int rows, int cols, int width,
  368.                                   int height, int wattr, int battr, char *box));
  369. void          WindowInitializeSystem P((void));
  370. int           WindowMakeNormal P((WPOINTER w));
  371. int           WindowMakeSeeThru P((WPOINTER w));
  372. int           WindowMove P((WPOINTER w, int row, int col));
  373. int           WindowMoveCursor P((WPOINTER w, int row, int col));
  374. int           WindowOpen P((WPOINTER w));
  375. int           WindowPositionViewport P((WPOINTER w, unsigned row, unsigned col));
  376. int           WindowPrintf P((WPOINTER w, char *format, ...));
  377. int           WindowPrintfAttr P((WPOINTER w, int attr, char *format, ...));
  378. int           WindowReadCharacters P((WPOINTER w, char *buffer, int row,
  379.                                       int col, int length));
  380. int           WindowReadAttributes P((WPOINTER w, char *buffer, int row,
  381.                                       int col, int length));
  382. int           WindowReadCharAndAttr P((WPOINTER w, char *buffer, int row,
  383.                                        int col, int length));
  384. int           WindowRemoveBorder P((WPOINTER w));
  385. int           WindowRemoveShadow P((WPOINTER w));
  386. int           WindowResizeHeight P((WPOINTER w, int height, int flag));
  387. int           WindowResizeWidth P((WPOINTER w, int width, int flag));
  388. int           WindowSaveInitial P((int page));
  389. int           WindowScroll P((WPOINTER w, int lines, int direct));
  390. int           WindowScrollAttr P((WPOINTER w, int lines, int direct, int attr));
  391. int           WindowScrollRegion P((WPOINTER w, int lines, int urow, int ucol,
  392.                                     int lrow, int lcol, int direct));
  393. int           WindowScrollRegionAttr P((WPOINTER w, int lines, int urow,
  394.                                         int ucol, int lrow, int lcol, int direct,
  395.                                         int attr));
  396. int           WindowScrollViewport P((WPOINTER w, unsigned units, int direct));
  397. int           WindowSetWrap P((WPOINTER w, int flag));
  398. int           WindowSlide P((WPOINTER w, int direct, int num));
  399. int           WindowSyncCursor P((WPOINTER w, int flag));
  400. int           WindowWriteAttributes P((WPOINTER w, char *buffer, int row,
  401.                                        int col, int length));
  402. int           WindowWriteCharacters P((WPOINTER w, char *buffer, int row,
  403.                                        int col, int length));
  404. int           WindowWriteCharAndAttr P((WPOINTER w,char *buffer, int row,
  405.                                         int col, int length));
  406. int           WindowWriteCharactersAttr P((WPOINTER w, char *buffer, int row,
  407.                                            int col, int attr, int length));
  408. int           WindowWriteCenterString P((WPOINTER w, char *string, int row));
  409. int           WindowWriteCenterStringAttr P((WPOINTER w, char *string, int row,
  410.                                              int attr));
  411. int           WindowWriteRepeatAttribute P((WPOINTER w, int attr, int row,
  412.                                             int col, int length));
  413. int           WindowWriteRepeatCharacter P((WPOINTER w, int attr, int row,
  414.                                             int col, int length));
  415. int           WindowWriteString P((WPOINTER w, char *string, int row, int col));
  416. int           WindowWriteStringAttr P((WPOINTER w, char *string, int row,
  417.                                        int col, int attr));
  418. int           WindowWriteStringRJ P((WPOINTER w, char *string, int row, int col));
  419. int           WindowWriteStringRJAttr P((WPOINTER w, char *string, int row,
  420.                                          int col, int attr));
  421. int           WindowWriteStringCC P((WPOINTER w, char *string, int row, int col));
  422. int           WindowWriteStringCCAttr P((WPOINTER w, char *string,int row,
  423.                                          int col, int attr));
  424. int           WindowWriteTextToFile P((WPOINTER w, char *string, int mode));
  425.  
  426. #if !defined (SOUND_DEF)
  427. #define SOUND_DEF
  428.  
  429. #if defined (POWERC)
  430. void          cwlsound P((UNKNOWNARGS));
  431.   #define sound(x)      cwlsound(x)
  432. #endif
  433.  
  434. #endif
  435.  
  436.  
  437. #if !defined (__TURBOC__)
  438. void         delay P((unsigned));
  439. #if !defined (POWERC)
  440. void         sound P((unsigned));
  441. #endif
  442. void         nosound P((void));
  443. #endif
  444.  
  445.  
  446. #if defined (SOURCE)
  447. #include "internal.h"
  448. #endif
  449.  
  450. #undef P
  451. #if __cplusplus
  452.   }
  453. #endif
  454.  
  455. #endif
  456.